<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-island-scenic__isscenicspot">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.scenicSpotName" placeholder="景区名称" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <SelectComponent v-model="dataForm.sort" placeholder="价格升序" :options="options">
          </SelectComponent>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t("query") }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
        style="width: 100%" height="calc(100vh - 270px)">
        <el-table-column type="selection" :show-overflow-tooltip="true" align="center" width="50"></el-table-column>
        <!-- <el-table-column prop="id" label="" header-align="center" align="center"></el-table-column> -->
        <el-table-column prop="spid" label="编号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="scenicSpotName" label="景区名称" :show-overflow-tooltip="true"
          align="center"></el-table-column>
        <el-table-column prop="scenicName" label="所属区域" :show-overflow-tooltip="true" align="center"></el-table-column>
        <el-table-column prop="startPrice" label="起步价格" :show-overflow-tooltip="true" align="center"></el-table-column>
        <el-table-column prop="coverImage" label="封面图" header-align="center" align="center">
          <template slot-scope="scope">
            <el-image :src="scope.row.coverImage" />
          </template>
        </el-table-column>
        <el-table-column prop="openDate" label="开放时间" :show-overflow-tooltip="true" align="center"></el-table-column>
        <el-table-column prop="address" label="景区地址" :show-overflow-tooltip="true" align="center"></el-table-column>
        <el-table-column prop="isHotName" label="是否热门" :show-overflow-tooltip="true" align="center"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" :show-overflow-tooltip="true" align="center" width="150">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="viewHandle(scope.row)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
        layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"
        @changeDisabled="disabled = false" :disabled="disabled"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./isscenicspot-add-or-update";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      disabled: false,
      mixinViewModuleOptions: {
        getDataListURL: "/scenic/isscenicspot/page",
        getDataListIsPage: true,
      },
      dataForm: {
        scenicSpotName: '',
        sort: '',
      },
      options: [{
        dictValue: 0,
        dictLabel: "降序"
      },
      {
        dictValue: 1,
        dictLabel: "升序"
      },
      ],
    };
  },
  watch: {},
  components: {
    AddOrUpdate,
  },
  methods: {
    viewHandle(row) {
      this.addOrUpdateVisible = true;
      this.disabled = true;
      this.$nextTick(() => {
        this.$refs.addOrUpdate.visible = true;
        this.$refs.addOrUpdate.dataForm.id = row.spid;
        this.$refs.addOrUpdate.init();
      });
    },
  },
};
</script>
